<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    /*
       (0)
     */
    function getRandomNum(min = 1, max = 100) {
        return Math.floor(Math.random() * (max - min + 1) + min)
    }

    /*
        let map = new Map()
        let start = 1, end = 10
        for (let i = start; i <= end; i++) {
            map.set(i, 0)
        }
    
        for (let i = 0; i < 100000; i++) {
            let result = getRandomNum(start, end)
            map.set(result, map.get(result) + 1)
        }
        console.log(map)*/

    function justDoIt() {
        const promise = new Promise(((resolve, reject) => {
            if (getRandomNum(1, 100) > 50) {
                setTimeout(resolve, 1000,'success')
            } else {
                setTimeout(reject, 1000,'failure')
            }
        }))
        return promise;
    }

    const thePromise = justDoIt()
    thePromise.then(console.log,console.log)

</script>
</body>
</html>